<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 数据表格</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">


    <style>

        th,td{
            text-align: center;
        }
        th{
            width: 143px;
        }
        #layer-date {
            position: absolute;
            left: 100px;
            top: 60px;
            z-index: 1000;
            padding: 0;
            margin-left: 200px;
            margin-top: -5px;
            margin-bottom: -31px;
            border: 0;
            width: 550px;
            float: left;
        }
    </style>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>账户在线 ：{{ $data['num'] }}</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="table_data_tables.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="table_data_tables.html#">选项1</a>
                            </li>
                            <li><a href="table_data_tables.html#">选项2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">


                    <form method="post" action="/online" role="form" >
                        <div class="form-group" id="layer-date" >
                            <div class="col-sm-5" style="width: 220px;">
                                <input class="form-control layer-date"  name="start_date" value="" placeholder="请选择开始时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                            </div>
                            {!! csrf_field() !!}
                            <div class="col-sm-5" style="width: 220px;">
                                <input class="form-control layer-date" name="end_date" value="" placeholder="请选择结束时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                            </div>
                            <button class="btn btn-primary" style="margin-left: 15px; margin-top: 1px;" type="submit">查询</button>
                        </div>
                    </form>

                    <table class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>用户名</th>
                            <th>在线线路数</th>
                            <th>开始时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @if(!empty($data['online']))
                            @foreach($data['online'] as $value)
                                <tr class="gradeX">
                                    <td>{{ $value['radacctid'] }}</td>
                                    <td>{{ $value['username'] }}</td>
                                    <td>{{ $value['num'] }}</td>
                                    <td>{{ $value['acctstarttime'] }}</td>
                                    <td>
                                        <a class="btn btn-success " href="/getaccountonlieInfo?account_id={{ $value['user_id'] }}"  type="button">详情</a>
                                        {{--<button user="{{ $value['username']}}" sessionid="{{ $value['acctsessionid'] }}" lanip="{{ $value['framedipaddress'] }}" rosip="{{ $value['calledstationid'] }}" radacctid="{{ $value['radacctid'] }}" class="btn btn-w-m btn-danger"   type="button"><i class="fa fa-paste"></i> 禁用</button>--}}
                                    </td>
                                </tr>
                            @endforeach
                        @endif
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>



<script src="js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>


<script src="js/plugins/layer/laydate/laydate.js"></script>
<!-- Page-Level Scripts -->
<script>

    $(function(){


        $('.btn-danger').on('click',function(){

            if(confirm('禁用以后，正在使用用户将强制下线'))
            {
                var user = $(this).attr('user');
                var sessionid = $(this).attr('sessionid');
                var lanip = $(this).attr('lanip');
                var rosip = $(this).attr('rosip');
                var radacctid = $(this).attr('radacctid');
                $_this = $(this);

                $.ajax({
                    url:'/forbiddenAaccount',          //  删除账号
                    type:'get',
                    data:{
                        user: user,
                        sessionid: sessionid,
                        lanip: lanip,
                        rosip: rosip,
                        radacctid: radacctid
                    },
                    timeout:5000,
                    dataType:'json',
                    success:function(data,textStatus,jqXHR){
                        if(data.error_code==0){
                            if(data.data=='SUCCESS'){
                                $_this.parent().parent().remove();
                                alert('禁用成功');
                            }else{
                                alert('禁用失败');
                            }
                        }else{
                            layer.msg(data.error_message);
                        }
                    },
                    error:function(xhr,textStatus){
                        alert('失败！');
                    }
                })
            }

        });
    });


    $(document).ready(function () {
        $('.dataTables-example').dataTable();

        /* Init DataTables */
        var oTable = $('#editable').dataTable();

        /* Apply the jEditable handlers to the table */
        oTable.$('td').editable('../example_ajax.php', {
            "callback": function (sValue, y) {
                var aPos = oTable.fnGetPosition(this);
                oTable.fnUpdate(sValue, aPos[0], aPos[1]);
            },
            "submitdata": function (value, settings) {
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTable.fnGetPosition(this)[2]
                };
            },

            "width": "90%",
            "height": "100%"
        });


    });

    function fnClickAddRow() {
        $('#editable').dataTable().fnAddData([
            "Custom row",
            "New row",
            "New row",
            "New row",
            "New row"]);

    }
</script>




</body>

</html>
